import openpyxl
from openpyxl.workbook import Workbook
from openpyxl.worksheet.worksheet import Worksheet


class DoTxt_file():
    def a(self,f1,m,isUTF=False):
        #f=r'F:\work\codings\python\pro_test\file\新建文本文档 (2).txt'

        if isUTF:
            with open(f1,m,encoding='utf-8')as ff :
                #ff.read()
                print(ff.read())
                return ff.read()
        else:
            with open(f1,m)as ff:
                #ff.read()
                print(ff.read())
                return ff.read()


       # print('开始读')
        #print(ff.read())
        # s = ff.close()


    def doWirt(self,f,m,mm,isUTF=False):
        # if isUTF:
        #     ff=open(f,mode=m,encoding='utf-8')
        # else:
        #     ff = open(f,mode=m)
        #
        # print(ff.write(mm))
        # s=ff.close()
        # return s
        if isUTF:
            with open(f,mode=m,encoding='utf-8') as ff:
                ff.write(mm)
        else:
            with open(f,mode=m)as ff :
                ff.write(mm)

        # print(ff.write(mm))
        #
        # return ff.write(mm)

    # excel
    def doReadE(self,f):
        wk:Workbook=openpyxl.load_workbook(f)
        st:Worksheet=wk['Sheet2']
        s=st.iter_rows(3,4,1,3,values_only=True)
        l=[i for i in s]
        print(l)
        return l














if __name__=='__main__':
    df=DoTxt_file()
    # f=r'F:\work\codings\python\pro_test\file\新建文本文档 (2).txt'
    # f00 = r'F:\work\codings\python\pro_test\file\nihao.txt'
    # f1=r'F:\work\codings\python\pro_test\file\8a06236f9ca1957814a3311edbdad6da.jpg'
    # c=df.a(f1,'rb')
    # f11=r'F:\work\codings\python\pro_test\file\12.jpg'
    # df.a(f,'r',True)
    # #df.a(f1, 'rb')
    # df.doWirt(f1,'w','你好',True)
    l1=r'F:\work\codings\python\pro_test\file\新建 XLSX 工作表 (2).xlsx'
    df.doReadE(l1)

